' ======================================================================
' 执行所有测试用例
' ======================================================================
Public Sub test_all_case()
    ' 测试: 初始化时的默认值
    test_default_value
    ' 测试: 更新属性
    test_udpate_field
    ' 测试: 获取对齐元素分组的对齐器
    test_getAligner
End Sub

' ======================================================================
' 配置器方法测试
' ======================================================================
' 测试: 初始化时的默认值
Private Sub test_default_value()
    Dim config As SqlFormatterConfiguration
    Set config = New SqlFormatterConfiguration

    Debug.Assert config.firstConditionNeedFillSpace = True
    Debug.Assert config.multiNestAlignmentStrSizeDiff = 10
    Debug.Assert config.alignmentLevel = SqlAlignmentLevel.INTERNAL
    Debug.Assert config.elemNestLevelPrefixSpaceCount = 4
    Debug.Assert config.lineBreak = vbCrLf
    Debug.Assert config.alignmentPosition = SqlAlignmentPosition.OPERATOR_RIGHT
    Debug.Assert config.elemNestLevelPrefixSpace = "    "
    Debug.Assert config.insertColListNeedLineBreakAfterComma = True
    Debug.Assert config.needSqlEndSemicolon = True
End Sub

' 测试: 更新属性
Private Sub test_udpate_field()
    Dim config As SqlFormatterConfiguration
    Set config = New SqlFormatterConfiguration

    config.firstConditionNeedFillSpace = False
    Debug.Assert config.firstConditionNeedFillSpace = False

    config.multiNestAlignmentStrSizeDiff = 8
    Debug.Assert config.multiNestAlignmentStrSizeDiff = 8

    config.alignmentLevel = SqlAlignmentLevel.ALL_LEVEL
    Debug.Assert config.alignmentLevel = SqlAlignmentLevel.ALL_LEVEL

    config.elemNestLevelPrefixSpaceCount = 2
    ' 两个属性联动，需要一起检查
    Debug.Assert config.elemNestLevelPrefixSpaceCount = 2
    Debug.Assert config.elemNestLevelPrefixSpace = "  "

    config.lineBreak = vbLf
    Debug.Assert config.lineBreak = vbLf

    config.insertColListNeedLineBreakAfterComma = False
    Debug.Assert config.insertColListNeedLineBreakAfterComma = False
    config.insertColListNeedLineBreakAfterComma = True
    Debug.Assert config.insertColListNeedLineBreakAfterComma = True

    config.needSqlEndSemicolon = False
    Debug.Assert config.needSqlEndSemicolon = False
    config.needSqlEndSemicolon = True
    Debug.Assert config.needSqlEndSemicolon = True
End Sub

' 测试: 获取对齐元素分组的对齐器
Private Sub test_getAligner()
    Dim config As SqlFormatterConfiguration
    Set config = New SqlFormatterConfiguration

    ' 测试两次获取到的对齐器是同一个对象
    Dim aligner01 As SqlFormatterAligner
    Dim aligner02 As SqlFormatterAligner

    Set aligner01 = config.getAligner
    Set aligner02 = config.getAligner

    Debug.Assert aligner01 Is aligner02
End Sub